package com.atguigu.crowd.mvc.controller;


import com.atguigu.crowd.service.api.AdminService;
import crowd.entity.Admin;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Controller
public class TestController {

    @Autowired
    private AdminService adminService;


    @RequestMapping("/test/ssm.html")
    public String testSSM(ModelMap modelMap){

        List<Admin> adminList = adminService.getAll();
        modelMap.addAttribute("adminList", adminList);
        System.out.println(10 / 0);
        return "target";
    }

    @ResponseBody
    @RequestMapping("/send/array.html")
    public String testReceiveArrayone(@RequestParam("array[]") List<Integer> array){
        for (Integer num : array) {
            System.out.println(num);
        }
        return "success";
    }

    @ResponseBody
    @RequestMapping("/send/array/two.html")
    public String testReceiveArrayone2(@RequestBody List<Integer> array2){
        for (Integer num :
                array2) {
            log.info("num:" + num);
        }
        return "success";
    }

//    @ResponseBody
//    @RequestMapping("/send/compose/object.html")
//    public String testRectiveComposeObject(@RequestBody Student student){
//        log.info(student.toString());
//        return "success";
//    }
}
